package cn.daixi.web.sys.controller;

import cn.daixi.web.sys.dto.TableColumnRes;
import cn.daixi.web.sys.dto.TableRes;
import cn.daixi.web.sys.service.SysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

@RestController
@RequestMapping("sys")
public class SysController {
    @Autowired
    private SysService sysService;

    @PostMapping("tableColumns")
    public List<TableColumnRes> tableColumns(@RequestParam("table") String table) throws SQLException {
        return sysService.getTableColumns(table);
    }

    @PostMapping("tables")
    public List<TableRes> tables() throws SQLException {
        return sysService.getTables();
    }
}
